package pqt;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Toolkit;

public class Balanza extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			Balanza dialog = new Balanza();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public Balanza() {
		setTitle("Balanza");
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		setIconImage(Toolkit.getDefaultToolkit().getImage(Balanza.class.getResource("/img/icono.png")));
		setModal(true);
		setBounds(100, 100, 638, 425);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBackground(new Color(204, 204, 204));
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
//----------------------------------------------Boton Aceptar------------------------------------------------------------
	
		final JButton btnBalanzaAceptar = new JButton("");
			btnBalanzaAceptar.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					dispose();
				}
			});
			btnBalanzaAceptar.setFocusable(true);
			btnBalanzaAceptar.setContentAreaFilled(false);
			btnBalanzaAceptar.setBorderPainted(false);
			btnBalanzaAceptar.setBorder(null);
			btnBalanzaAceptar.setBounds(116, 235, 374, 100);
			btnBalanzaAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/AceptarAzulGrande.png")));
			btnBalanzaAceptar.setPressedIcon(new ImageIcon(testBoton.class.getResource("/img/AceptarBlancoGrande.png")));
			contentPanel.add(btnBalanzaAceptar);
			
			btnBalanzaAceptar.addMouseListener(new MouseAdapter() {
				
				public void mouseEntered(MouseEvent arg0) {
					btnBalanzaAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/AceptarVerdeGrande.png")));
					getRootPane().setDefaultButton(btnBalanzaAceptar);
					
				}
				public void mouseExited(MouseEvent e) {
					btnBalanzaAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/AceptarAzulGrande.png")));
					getRootPane().setDefaultButton(null);
				}
			});
			btnBalanzaAceptar.addFocusListener(new FocusAdapter() {
				@Override
				public void focusGained(FocusEvent arg0) {
					btnBalanzaAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/AceptarVerdeGrande.png")));
					getRootPane().setDefaultButton(btnBalanzaAceptar);
				}
				@Override
				public void focusLost(FocusEvent e) {
					btnBalanzaAceptar.setIcon(new ImageIcon(testBoton.class.getResource("/img/AceptarAzulGrande.png")));
					getRootPane().setDefaultButton(null);
				}
			});
	
//------------------------------------------------------------------------------------------------------------------------
		{
			textField = new JTextField();
			textField.setFont(new Font("Tahoma", Font.PLAIN, 40));
			textField.setBounds(63, 117, 494, 67);
			textField.addActionListener(	new ActionListener() {

		        @Override
		        public void actionPerformed(ActionEvent arg0) {
		            // Se transfiere el foco al siguiente elemento.
		            ((JTextField) arg0.getSource()).transferFocus();
		        }
		    });
			contentPanel.add(textField);
			textField.setColumns(10);
		}
//--------------------------------------------------------------------------------------------------------------------
		{
			JLabel lblIngreseElModelo = new JLabel("Ingrese equipo a ensayar");
			lblIngreseElModelo.setFont(new Font("Tahoma", Font.PLAIN, 40));
			lblIngreseElModelo.setHorizontalAlignment(SwingConstants.CENTER);
			lblIngreseElModelo.setBounds(10, 21, 602, 60);
			
			
			contentPanel.add(lblIngreseElModelo);
		}
	}

}
